package com;

import com.milling.common.utils.StringUtils;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.Socket;

public class TestSocket88 {
    public static void main(String[] args) {



        while(true) {
            try {
//                Socket socket = new Socket("192.168.237.66", 2001);
                Socket socket = new Socket("localhost", 2003);
                OutputStream outputStream = socket.getOutputStream();
                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(socket.getInputStream()));

//            outputStream.write("start".getBytes());
//            outputStream.flush();

                String response = bufferedReader.readLine();
                if(StringUtils.isNotEmpty(response)) {
                    System.out.println("Received response: " + response); // 添加日志输出接收到的信息
                }
            } catch (IOException e) {
                e.printStackTrace();
                System.out.println("Socket connection error: " + e.getMessage());
            }
        }
    }




}




